import pymysql

# 创建数据库连接池
from dbutils.pooled_db import PooledDB
from openai import OpenAI


########## Ai配置
client = OpenAI(
    # 若没有配置环境变量，请用百炼API Key将下行替换为：api_key="sk-xxx",
    api_key="sk-80343c1ec74f43bba6a8ad2d01d19068",
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)

# 模型列表，按顺序调用
MODEL_LIST = [
    "deepseek-r1-distill-llama-8b"
]

MAX_CALLS_PER_MODEL = 999999999
STATE_FILE = "./model_state.json"



######### 数据库配置
# 创建连接池
pool = PooledDB(
    creator=pymysql,  # 使用pymysql作为数据库连接器
    maxconnections=6,  # 连接池最大连接数
    mincached=2,      # 初始化时，连接池中至少创建的空闲的链接
    maxcached=5,      # 连接池中最多闲置的链接
    maxshared=3,      # 链接最大共享数
    blocking=True,    # 连接池中如果没有可用连接后，是否阻塞等待
    maxusage=None,    # 一个链接最多被重复使用的次数，None表示无限制
    setsession=[],    # 开始会话前执行的命令列表
    ping=0,           # ping MySQL服务端，检查是否服务可用
    host='1.194.161.112',
    user='root',
    port=13049,
    password='mh1e!8:G.@Jg^CD',
    database='mapping_and_api',
    charset='utf8mb4'
)

# 从连接池获取连接
conn = pool.connection()
cursor = conn.cursor()


REMOTE_DB_PUSH_URL = "http://xdrj.lottefuture.com/zxy/V1/Gen2/ed1XF/ZhiDeMaiController/receive/method"


########## 请求配置
# PROXIES = {
#     "http": "http://127.0.0.1:9000",  # HTTP 代理地址
#     "https": "http://127.0.0.1:9000",  # HTTPS 代理地址
# }

PROXIES = None

# COOKIES = {
#         # 必不可少  可以固定死？
#         'w_tsfp': 'ltvuV0MF2utBvS0Q7a3rnUytEzomfDo4h0wpEaR0f5thQLErU5mB1oRzucjyM3Tf6sxnvd7DsZoyJTLYCJI3dwMUTcSTIN8Vj1/BwNB33IcVVBJkE5iNDFAeJ7x05DJHfHhCNxS00jA8eIUd379yilkMsyN1zap3TO14fstJ019E6KDQmI5uDW3HlFWQRzaLbjcMcuqPr6g18L5a5WyP7Vr5L1hyUrkT0E2QhC4cWi126RG6J+ldZEj4cZutSqA=',
#     }

HEADERS = {
    'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
    'accept-language': 'zh-CN,zh;q=0.9',
    'cache-control': 'no-cache',
    'pragma': 'no-cache',
    'priority': 'u=0, i',
    'referer': 'https://www.smzdm.com/jingxuan/',
    'sec-ch-ua': '"Chromium";v="136", "Google Chrome";v="136", "Not.A/Brand";v="99"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'document',
    'sec-fetch-mode': 'navigate',
    'sec-fetch-site': 'same-origin',
    'sec-fetch-user': '?1',
    'upgrade-insecure-requests': '1',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36',
    # 'cookie': 'Hm_lvt_9b7ac3d38f30fe89ff0b8a0546904e58=1746501928,1747183650,1747269427,1747294902; sajssdk_2015_cross_new_user=1; smzdm_ec=06; smzdm_ea=01; HMACCOUNT=31C9A752D83A43E6; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22196d2e7d7523d4-0e523e3a033b11-26011f51-3686400-196d2e7d753236c%22%2C%22first_id%22%3A%22%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_landing_page%22%3A%22https%3A%2F%2Fwww.smzdm.com%2Fp%2F147933764%2F%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTk2ZDJlN2Q3NTIzZDQtMGU1MjNlM2EwMzNiMTEtMjYwMTFmNTEtMzY4NjQwMC0xOTZkMmU3ZDc1MzIzNmMifQ%3D%3D%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%22%2C%22value%22%3A%22%22%7D%2C%22%24device_id%22%3A%22196d2e7d7523d4-0e523e3a033b11-26011f51-3686400-196d2e7d753236c%22%7D; __ckguid=5Lc5E73aiKYx4gL92QPN5AIn7; device_id=20742009451747295418675466302a5de7cb7f388b6c8f661b6c82ea83; _zdmA.time=1747297046225.2388.https%3A%2F%2Fwww.smzdm.com%2F; Hm_lpvt_9b7ac3d38f30fe89ff0b8a0546904e58=1747297103; w_tsfp=ltvuV0MF2utBvS0Q7a3rnUytEzomfDo4h0wpEaR0f5thQLErU5mB1oRzucjyM3Tf6sxnvd7DsZoyJTLYCJI3dwMUTcSTIN8Vj1/BwNB33IcVVBJkE5iNDFAeJ7x05DJHfHhCNxS00jA8eIUd379yilkMsyN1zap3TO14fstJ019E6KDQmI5uDW3HlFWQRzaLbjcMcuqPr6g18L5a5WyP7Vr5L1hyUrkT0E2QhC4cWi126RG6J+ldZEj4cZutSqA=',
}

########## 路径配置
DRIVER_PATH = "pass_by_selenium/chromedriver-win64/chromedriver.exe"

JS_PATH = 'pass_by_selenium/drag_captcha'

OTHER_PATH = "./other/"

###########  其它

# 平台
PLATFORM_LIS = ["京东", "淘宝","拼多多","唯品会"]

# 平台解析接口
url_map = {
        "京东": "http://cgi-bin.lottefuture.com/python/jd-goods-query.php",
        "淘宝": "http://cgi-bin.lottefuture.com/python/taobao-goods-query.php",
        "拼多多":"http://cgi-bin.lottefuture.com/python/pdd-goods-query.php",
        "唯品会":"http://cgi-bin.lottefuture.com/python/vipshop-goods-query.php",
    }

